function PyResult() {
    this.form = this.InitForm();
    this.table = this.InitTableByBt();
}

PyResult.prototype.InitForm = function () {
    var form;
    layui.use('form', function () {
        form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功
        form.render();
    });
    return form;
}

var _table;
PyResult.prototype.InitTableByBt = function () {
    var table;
    var _this = this;
    var index = layer.load();
    var year = $('#hidyear').val();
    var quarter = $('#hidquarter').val();
    layui.use('table', function () {
        table = layui.table;
        table.init('uatmzpdsummarylist', {
            height: $(window).height() - 100
            , url: 'get_season_list' // 数据接口
            , page: false // 开启分页
            // ,limit : 30
            , id: 'uatmzpdsummary'
            , method: "post"
            , request: {
                type: 'post'
            }
            , where: {
                year: year,
                quarter: quarter,
                orgid: 19
            }
            , done: function (res, page, count) {


                $("#title1").html(year + "年第" + quarter + "季度");
                layer.close(index);
            }
        });
    })
    _table = table;
    return table;
}


PyResult.prototype.searchtable = function () {
    _table.reload('uatmzpdsummary', {

        where: {
            year: $("#year").val(),
            quarter: $('input[name="quarter"]:checked ').val(),
            orgid: $("#szdw").val()
        }
    });
}


PyResult.prototype.excle = function () {
    top.ShowZheZhao();
    var tabledataJson = this.table.cache;
    var year = $("#year").val();
    var quarter = $('input[name="quarter"]:checked ').val();
    var orgname = $.trim($("#szdw").find("option:selected").text());
    tabledataJson['yearid'] = year;
    tabledataJson['quarter'] = quarter;
    tabledataJson['orgname'] = orgname;
    tabledataJson = JSON.stringify(tabledataJson);
    tabledataJson = tabledataJson.replace(/LAY_TABLE_INDEX/g, 'lay_TABLE_INDEX');
    $.ajax({
        type: "POST",
        url: "export_season_mzpd",
        contentType: 'application/json',
        data: tabledataJson,
        beforeSend: function (XHR) {

        },
        success: function (data) {
            data = eval('(' + data + ')');
            if (data.result > 0) {
                //top.mylayui.msg('导出成功', {icon: 1});
                window.open(data.msg, '_self');
            }
            else {
                top.mylayui.msg(data.msg, {icon: 0});
            }
            top.ShowZheZhao();
        },
        complete: function (XHR) {
            top.mylayui.closeAll('loading');
        },
        error: function () {

        }
    });
}


var vSeasonUATMzpd = null;
$(function () {
    vSeasonUATMzpd = new PyResult();
})